<?php

namespace App\Console\Commands;

use App\Http\Model\Gift;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\Room;

class CreateMonthStream extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'createMonthStream {date=0}';

    /**
     * The console command description.
     *
     * @return void
     * @var string
     *
     * protected $description = '生成用户&房间收礼物月统计-->公会缓存';
     *
     * /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $startTime = strtotime(date('Y-m-01 00:00:00', strtotime('-1 month', time())));
        $endTime = strtotime(date('Y-m-t 23:59:59', strtotime('-1 month', time())));
        $all = (int)$this->argument('date');
        if ($all !== 0) {
            $startTime = strtotime(date('Y-m-01 00:00:00', strtotime($all)));
            $endTime = strtotime(date('Y-m-t 23:59:59', strtotime($all)));
        }
        $giftModel = new Gift();
        $giftModel->getMonthGiftUserSumCache($startTime, $endTime);
        $giftModel->getMonthGiftRoomSumCache($startTime, $endTime);
    }

}
